"""
@Project: pythonPro1
@Name: _01video.py
@Author: linxin_liu
@Date: 2022/10/12 9:34
"""
import cv2

vc = cv2.VideoCapture('D:/tools/image_operation/scenery.mp4')
if vc.isOpened():
    open_vc, frame = vc.read()  # 如果当前帧可以读出来，open_cv为true,反之亦然，frame为当前帧(的像素矩阵)
# print(type(True))
else:
    open_vc = False
while open_vc:
    temp_open, frame = vc.read()
    if frame is None:
        break
    if temp_open:
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        cv2.imshow('result', gray)
        if cv2.waitKey(50) & 0xFF == 27:  # 27为退出键
            break
vc.release()
cv2.destroyAllWindows()






